﻿
namespace Codemonk.Updater.Client.Common
{
    internal static class UpdateClientManager
    {
        private static IUpdateClient updateClient;

        public static IUpdateClient GetClient(string server)
        {
            if (updateClient != null) return updateClient;
            if (server.Length < 3) return null;
            if ("tcp" == new string(new char[] { server[0], server[1], server[2] })) return updateClient = new SocketUpdateClient { RequestAddress = server };
            if (server.Length < 4) return null;
            if ("http" == new string(new char[] { server[0], server[1], server[2], server[3] })) return updateClient = new HttpUpdateClient { RequestAddress = server };
            return null;
        }
    }
}
